<template>
    <div>
        <create-order v-model:dialogDrawer="dialogCreate" :title="title" v-model:defaultForm="rowForm" v-model:isEdit="isEdit"></create-order>
    </div>
</template>

<script>
import { reactive, toRefs, onMounted, computed, h } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import CreateOrder from '../../order/components/CreateOrder.vue'

import Cookies from 'js-cookie'
import api from '/@/api/commonApi'

export default {
    name: 'wechatOrder',
    components: {
        CreateOrder
    },
    setup() {
        const router = useRouter()
        const state = reactive({
            dialogCreate: false,
            rowForm: {},
            title: '查看订单',
            isEdit: true,
        })
        // 获取订单详情
        const orderInfo = (orderId) => {
            api.getOrderById(orderId).then(res => {
                state.rowForm = res.data
                state.rowForm.deliveryType = Number(state.rowForm.deliveryType)
                state.rowForm.deliveryCompany = Number(state.rowForm.deliveryCompany)
                state.rowForm.payStatus = Number(state.rowForm.paymentTime?1:0)
                state.rowForm.logisticStatus = Number(state.rowForm.deliveryTime?1:0)
                api.getBelongerName({userId: res.data.belongerId}).then(resp => {
                    state.rowForm.belongerName = resp.name
                    state.dialogCreate = true
                })
            })
        }


        onMounted(() => {
            orderInfo(router.currentRoute.value.params.id)
        })
        return {
            ...toRefs(state),
            orderInfo,
        }
    }
}
</script>

<style lang="scss">

</style>